package com.example.suuu.tools.security;

import com.example.suuu.project.system.entity.SuUser;
import com.example.suuu.project.system.entity.vo.MyUserDetails;
import org.springframework.security.core.context.SecurityContextHolder;

import java.util.List;

public class SecurityUtils {
    /**
     * 获取当前登录用户
     * @return
     */
    public static SuUser LoginUsers(){
        MyUserDetails u = (MyUserDetails) SecurityContextHolder.getContext()
                .getAuthentication()
                .getPrincipal();
        return u.getUser();
    }

    /**
     * 获取当前登录用户权限信息
     * @return
     */
    public static List<String> Permissions(){
        MyUserDetails u = (MyUserDetails) SecurityContextHolder.getContext()
                .getAuthentication()
                .getPrincipal();
        return u.getPermissions();
    }
}
